(()=>{"use strict";const e="Tag Manager: ",t=function(){let e=!1;try{const t=window;e=t&&t.debug||t.location&&(t.location.search||"").toLowerCase().indexOf("debug=")>-1}catch(e){}return e}();function n(n){t&&console&&console.error(`${e} ${n}`)}function o(e){let t=e;try{t=JSON.parse(e)}catch(e){n("Parse error in string"),n(e.message)}return t}function r(e){return o(JSON.stringify(e))}function i(e,t){return!(!e||"true"!==e[t])}const c="_api/tag-manager/api/v1/tags/",a=`${c}sites/`,s=[".wix.com",".editorx.com"],d="22bef345-3c5b-4c18-b782-74d4085112ff",u="specs.tagManagerRenderTagByPageID",l="specs.tagManager.ReadLoadOnceFromTag",f=!!document.documentMode;function g(e,t,n){let o;f?(o=document.createEvent("CustomEvent"),o.initCustomEvent(e,!0,!0,n)):o=new CustomEvent(e,{detail:n}),t&&t.dispatchEvent&&setTimeout((()=>{t.dispatchEvent(o)}),0)}const p={TAG_MANAGER_LOADED:"TagManagerLoaded",TAGS_LOADING:"LoadingTags",TAG_LOADED:"TagLoaded",TAG_LOAD_ERROR:"TagLoadError",TAG_MANAGER_CONFIG_SET:"TagManagerConfigSet"};let m=[];const h=[],y=[],E=[];let b,T=[],w={},A=!1;function I(){return E}function v(){return r(w)}function N(e){return Object.keys(e).filter((t=>!!e[t]&&-1===T.indexOf(t)))}function O(e){m=e}function C(){return r(m)}function x(e){h.push(e)}function S(){return r(h)}function P(e){y.push(e)}function L(){return r(y)}function M(){b||A||(A=!0)}function R(e){b||"function"!=typeof e||(b=e),A=!1}function D(){return b}function _(){if(A)return A=!1,d;const e=document.currentScript;let t=!1;let n;if(e instanceof HTMLScriptElement&&E.forEach((o=>{!t&&o.tag.appInfo&&o.embeddedNodes.forEach((r=>{var i;t||r===e&&(n=(null==(i=o.tag)||null==(i=i.appInfo)?void 0:i.id)||"",t=!0)}))})),!n){const t=function(e){let t="Script not identified";if(e instanceof HTMLScriptElement){const{type:n,src:o}=e;t=`type: ${n||"No Type Found"} src: ${o||"No URL Found"}`}return t}(e),o=`App not found for script ${t}, errorId: 404C`;console.error(o),n=new Error(o)}return n}function $(e,t,o){const r=()=>{try{if("function"==typeof e)return e(t)}catch(e){n(e)}};return!0===o?setTimeout(r,0):r()}function G(e,t,n,o){return()=>{o(n),function(e){m=m.filter((t=>t.name!==e))}(n.name),g(e,window,{tagName:t,embed:r(n)})}}const j="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",k=j.length;function F(e,t){const n=function(){let e="";for(let t=0;t<16;t++)e+=j.charAt(Math.floor(Math.random()*k));return e}(),o=function(e){return`(function(getAccessToken){\n Object.defineProperty(globalThis, "${e}", {\n value: getAccessToken,\n enumerable: false,\n configurable: true,\n writable: true,\n });\n }(wixEmbedsAPI.getAccessTokenFunction()))`}(n),r=function(e,t,n){return`import { injectAccessTokenFunction } from "${e}";\n if(injectAccessTokenFunction){\n injectAccessTokenFunction(${t}, "${n}");\n } else {\n console.error("AppId ${n} does not expose function correctly, error code: Client 404");\n }`}(e,n,t),i=()=>{delete globalThis[id]};return{moduleScriptConfig:{node:{tag:"SCRIPT",attributes:{type:"module"},content:r},callbacks:{onload:function(){i(),this.parentNode.removeChild(this)},onerror:function(){i(),this.parentNode.removeChild(this)}}},helperScriptConfig:{tag:"SCRIPT",content:o}}}function H(e,t,n){let o;return e.nodeType===Node.TEXT_NODE?o=document.createTextNode(e.content):e.nodeType===Node.COMMENT_NODE?o=document.createComment(e.content):(o=document.createElement(e.tag),e&&e.attributes instanceof NamedNodeMap?Array.prototype.forEach.call(e.attributes,(e=>{U(o,e.name,e.value)})):"object"==typeof e.attributes&&Object.keys(e.attributes).forEach((t=>{void 0!==typeof e.attributes[t]&&U(o,t,e.attributes[t])})),"SCRIPT"===e.tag?o=function(e,t,n,o){void 0===t&&(t="");if(o&&"module"===e.getAttribute("type")&&"true"===e.getAttribute("accesstoken")){let r=e.src;!r&&t&&(r=B(t)),e=null;const{helperScriptConfig:i,moduleScriptConfig:c}=F(r,o),a=()=>{const e=H(c.node,c.callbacks,o);document.head.appendChild(e)};return H(i,{onload:a,onerror:null==n?void 0:n.onerror},o)}!function(e,t,n){void 0===t&&(t="");t&&(e.src=B(t));e.addEventListener("load",(function(){$(n&&n.onload,null)}),!1),e.addEventListener("error",(function(){$(n&&n.onerror,null)}),!1)}(e,t,n);return e}(o,e.content,t,n):e.children&&e.children.length>0&&e.children.forEach((e=>{const r=H(e,t,n);o.appendChild(r)}))),o}function U(e,t,n){e.setAttribute(t,n)}function B(e){const t=new Blob([e],{type:"text/javascript;charset=utf-8"});return URL.createObjectURL(t)}function q(e){const t=[],n=document.createElement("DIV");return n.innerHTML=e,Array.prototype.forEach.call(n.childNodes,(e=>{const n=J(e);t.push(n)})),t}function J(e){const t=e.nodeType,n=e.innerHTML||e.textContent||e.nodeValue,o=[];return e.hasChildNodes()&&Array.prototype.forEach.call(e.childNodes,(e=>{o.push(J(e))})),{nodeType:t,tag:e.nodeName,attributes:e.attributes,content:n,children:o}}let Y=function(e){return e.HEAD="head",e.BODY_START="bodyStart",e.BODY_END="bodyEnd",e}({});const z=e=>!e.id,V=e=>{var t;return!(null!=(t=e.tag)&&null!=(t=t.pages)&&t.length)},W=(e,t)=>{var n;return(null==(n=e.tag)||null==(n=n.pages)?void 0:n.includes(t.id||""))||!1};function X(e,t){return e.filter((e=>function(e,t){return z(t)||V(e)||W(e,t)}(e,t)))}function K(e,t,n){const o=e.filter((e=>!e.embeddedNodes)),r=i(n,u)?X(o,t):o,c=r.map((e=>e.tag));O(c),g(p.TAGS_LOADING,window,c),r.forEach((e=>{var t;const n=null==(t=e.tag.appInfo)?void 0:t.id;e.embeddedNodes=e.embeddedNodes||[];const o=e.tag,r=q(o.content),i=o.position&&o.position!==Y.HEAD?document.body:document.head;!function(e,t,n,o,r,i){let c=0;const a=()=>{c-=1,c>=0&&$(t.onload,{})},s=()=>{c-=1,c>=0&&$(t.onerror,{error:!0})},d=n.firstChild;e.forEach((e=>{"SCRIPT"===e.tag&&(c+=1);const t=H(e,{onload:a,onerror:s},i);r.push(t),o?n.insertBefore(t,d):n.appendChild(t)})),0===c&&$(t.onload,{},!0)}(r,{onload:G(p.TAG_LOADED,o.name,o,x),onerror:G(p.TAG_LOAD_ERROR,o.name,o,P)},i,o.position===Y.BODY_START,e.embeddedNodes,n)}))}function Q(e,t,n,o){const r=o&&o.headers||{},i=o&&o.query||{};r["content-type"]=r["content-type"]||"application/json";const c=new XMLHttpRequest,a=o&&o.postBody?"POST":"GET",s=`${e}${function(e){let t="";"object"==typeof e&&Object.keys(e).forEach((n=>{if(void 0!==e[n]){const o=encodeURIComponent(e[n]);t+=`${encodeURIComponent(n)}=${o}&`}}));return t=t?t.substr(0,t.length-1):"",t?`?${t}`:""}(i)}`;c.open(a,s,!0),c.onreadystatechange=()=>{if(4===c.readyState){const e=c.status;e<200||e>=300?$(n,{status:e,responseText:c.responseText}):$(t,c.responseText)}},Object.keys(r).forEach((e=>{void 0!==r[e]&&c.setRequestHeader(e,r[e])})),c.send(o&&o.postBody||null)}function Z(e,t){void 0===t&&(t=location.search);let n=t.split(`${e}=`)[1];return n=n?decodeURIComponent(n.split("&")[0]):void 0,n}function ee(e,t){const c=o(e),{currentPageID:a,initConsentPolicyManager:s=!1}=t;if(c.errors&&c.errors.length>0&&n(JSON.stringify(c.errors)),c.config){const e=window.consentPolicyManager;(u=c.config.consentPolicy)&&"object"==typeof u&&(T=[...T,...N(u)]),s&&e&&e.init({consentPolicy:c.config.consentPolicy}),"object"!=typeof(d=c.config)||Array.isArray(d)||(w={...w,...d},g(p.TAG_MANAGER_CONFIG_SET,window,r(w)))}var d,u,f,m;if(c.tags){f=c.tags,i(null==(m=w)?void 0:m.experiments,l)?f.forEach((e=>{var t;const n=e.loadOnce||(null==(t=e.content)?void 0:t.includes('load-once="true"'));E.push({tag:{...e,loadOnce:n},embeddedNodes:null})})):f.forEach((e=>{E.push({tag:e,embeddedNodes:null})}));const e={id:a};K(I(),e,c.config.experiments||{})}}const te=()=>"partytown"in window;function ne(e,t,n){return`${e&&!function(e){let t=!1;return s.forEach((e=>{t||(t=location.hostname.indexOf(e)>0)})),t||e}(!!n)?e:""}/${a}${t}`}async function oe(e){const{metasiteId:t,htmlsiteId:o,baseUrl:r,wixSite:i,language:c,categories:a}=e,s=Z("site-override"),u=Z("apps-override"),l=ne(r,t,i),f=window.consentPolicyManager,g=!i&&f?f._getConsentPolicyHeader():{},p=function(e){const t=e.wixEmbedsAPI,n=t&&t.getCurrentPageInfo;return"function"==typeof n?n():{}}(window),m=Z("omit"),h=await async function(){let e;const t=D();if("function"==typeof t)try{e=await t()}catch(e){}e||(e=$(window.wixEmbedsAPI.getAppToken,d));return e}();h&&(g.authorization=h),Q(l,(e=>{ee(e,{initConsentPolicyManager:!a&&!!i,currentPageID:p.id})}),(e=>{n(`Error loading site tags at ${l}`),n(e.message)}),{query:{wixSite:!!i,htmlsiteId:o,language:c,categories:a,omit:m,partytown:te(),siteOverrideId:s,appsOverrideId:u},headers:g})}function re(e){I().forEach((e=>{e.tag.loadOnce||(e.embeddedNodes&&e.embeddedNodes.forEach((e=>{$((()=>{e.parentNode.removeChild(e)}))})),e.embeddedNodes=null)}));K(I(),e,v().experiments||{})}function ie(e){if(e&&e.detail&&e.detail.policy){const t=N(e.detail.policy);t.length&&oe({baseUrl:window.wixEmbedsAPI.getExternalBaseUrl(),htmlsiteId:window.wixEmbedsAPI.getHtmlSiteId(),metasiteId:window.wixEmbedsAPI.getMetaSiteId(),wixSite:window.wixEmbedsAPI.isWixSite(),language:window.wixEmbedsAPI.getLanguage(),categories:t})}}!function(){const e=window;function t(){const t=e.wixEmbedsAPI;!function(){const t=Object.freeze({getLoadedTags:S,getLoadingTags:C,getLoadErrorTags:L,getConfig:v,getAppId:_});Object.defineProperty(e,"wixTagManager",{value:t,writable:!1,configurable:!1,enumerable:!0}),g(p.TAG_MANAGER_LOADED,window,window.wixTagManager)}(),function(e){if("function"==typeof e.getAccessTokenFunction){M();R(e.getAccessTokenFunction())}}(t),oe({baseUrl:t.getExternalBaseUrl(),htmlsiteId:t.getHtmlSiteId(),metasiteId:t.getMetaSiteId(),language:t.getLanguage(),wixSite:t.isWixSite()}),t.registerToEvent("pageNavigation",re),document.addEventListener("consentPolicyChanged",ie)}!function(){const n=e.wixEmbedsAPI;n&&"function"==typeof n.registerToEvent?t():e.addEventListener("wixEmbedsAPIReady",t,!1)}()}()})(); //# sourceMappingURL=siteTags.bundle.min.js.map